package com.sansan.qiangji.realize.warehouse;

import com.sansan.qiangji.VO.warehouse.stackerTaskOutVO.StackerTaskOutVO;
import com.sansan.qiangji.entity.warehouse.StackerTaskOut;
import com.sansan.qiangji.enums.ResultEnum;
import com.sansan.qiangji.exception.ServiceException;
import com.sansan.qiangji.service.impl.warehouse.StackerTaskOutServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
@Slf4j
public class StackerTaskOutReal {
    private StackerTaskOutServiceImpl stackerTaskOutService;

    @Resource
    public void setStackerTaskOutService(StackerTaskOutServiceImpl stackerTaskOutService){
        this.stackerTaskOutService = stackerTaskOutService;
    }

    public StackerTaskOutVO findByStackerTaskOutCode(String stackerTaskOutCode){
        StackerTaskOut stackerTaskOut = stackerTaskOutService.findByStackerTaskOutCode(stackerTaskOutCode);
        if (stackerTaskOut == null){
            log.error("【出库任务】出库任务不存在");
            throw new ServiceException(ResultEnum.STACKER_TASK_OUT_NOT_EXIST);
        }
        StackerTaskOutVO stackerTaskOutVO = new StackerTaskOutVO();
        BeanUtils.copyProperties(stackerTaskOut, stackerTaskOutVO);
        return stackerTaskOutVO;
    }
}
